<?php $this->load->view('header', $head);?>

<div data-role="page" id="create-poll">
	<div data-role="header">
		<h1>설문작성</h1>
	</div><!-- /header -->
	<div data-role="content">
		<?=form_open('ajax/create_poll', array('class' => 'ajax-form'))?>
			<ul data-role="listview" <?=$this->agent->is_mobile()?'':'data-inset="true"'?>>
				<li data-role="list-divider">
					필수 입력항목
				</li>
				<li data-role="fieldcontain">
					<label for="title">제목:</label>
					<input type="text" name="title" id="title" value="<?=set_value('title')?>" />
					<?=form_error('title')?>					
				</li>
				<li data-role="fieldcontain">
					<label for="category" class="select">분류:</label>
					<?=category_selector(set_value('category'))?>
				</li>
				<li data-role="fieldcontain">
					<label for="keyword">키워드:</label>
					<input type="text" name="keyword" id="keyword" value="<?=set_value('keyword')?>" />
					<?=form_error('keyword')?>					
				</li>
				<li data-role="fieldcontain">
					<label for="poll_start">설문시작 시점:</label>
					<input type="datetime" name="poll_start" id="poll_start" value="<?=set_value('poll_start')?>"/>
					<?=form_error('poll_date')?>
					<label for="poll_end">설문종료 시점:</label>
					<input type="datetime" name="poll_end" id="poll_end" value="<?=set_value('poll_end')?>"/>
					<?=form_error('poll_date')?>
				</li>
				<li data-role="fieldcontain">
					<fieldset data-role="controlgroup" data-type="horizontal">
						<legend>
							중간공개:
						</legend>
						<input type="radio" value="1" name="mid_show" id="radio-mid-show" <?=set_radio('mid_show', '1')?>/>
						<label for="radio-mid-show">공개</label>
						<input type="radio" value="0" name="mid_show" id="radio-not-mid-show" <?=set_radio('mid_show', '0', TRUE)?>/>
						<label for="radio-not-mid-show">비공개</label>
					</fieldset>
					<?=form_error('mid_show')?>
				</li>
				<li data-role="list-divider">
					선택 입력사항
				</li>
				<li data-role="fieldcontain">
					<fieldset data-role="controlgroup" data-type="horizontal" id="radio-limit">
						<legend>
							최대 인원:
						</legend>
						<input type="radio" value="1" name="limit" id="radio-limited" <?=set_radio('limit', '1', TRUE)?>)/>
						<label for="radio-limited">제한</label>
						<input type="radio" value="0" name="limit" id="radio-unlimited" <?=set_radio('limit', '0')?>/>
						<label for="radio-unlimited">무제한</label>
					</fieldset>
					<div id="max-people-container" style="display:none;">
						<label for="max_people"></label>
						<input type="number" name="max_people" id="max_people" value="<?=set_value('max_people','100')?>"/>
						<?=form_error('max_people')?>
					</div>
				</li>
				<li data-role="fieldcontain">
					<fieldset data-role="controlgroup" data-type="horizontal" id="radio-daily-period">
						<legend>
							유형:
						</legend>
						<input type="radio" name="type" value="once" id="radio-type-once" <?=set_radio('type', '1', TRUE)?>)/>
						<label for="radio-type-once">1회성</label>
						<input type="radio" name="type" value="repeat" id="radio-type-repeat" <?=set_radio('type', '0')?>/>
						<label for="radio-type-repeat">시간 반복형</label>
					</fieldset>
					<?=form_error('type')?>
				</li>
				<li data-role="fieldcontain" id="list-daily-period" style="display:none;">
					<label for="daily_start">시작시각:</label>
					<input type="time" name="daily_start" id="daily_start" value="<?=set_value('daily_start')?>"/>
					<?=form_error('daily_time')?>
					<label for="daily_end">종료시각:</label>
					<input type="time" name="daily_end" id="daily_end" value="<?=set_value('daily_end')?>"/>
					<?=form_error('daily_time')?>
				</li>
				<li data-role="fieldcontain">
					<label for="text-location">위치: </label>
					<input type="text" name="location" id="text-location" placeholder="시, 구, 동 기타 지역명"></input>
					<label for="location-list" class="location-fields"></label>
					<textarea id="location-list" disabled="true" style="display:none;resize:none;"></textarea>
					<p class="location-fields" style="display:none;"><a href="<?=site_url('poll/create_location')?>" data-role="button" data-rel="dialog" data-icon="+"/>위치 추가</a></p>
				</li>
				<li data-role="fieldcontain">
					<fieldset data-role="controlgroup" data-type="horizontal" id="radio-login-required">
						<legend>
							인증:
						</legend>
						<input type="radio" value="1" name="login_required" id="radio-login_required" <?=set_radio('login_required', '1')?>/>
						<label for="radio-login_required">회원</label>
						<input type="radio" value="0" name="login_required" id="radio-not_login_required" <?=set_radio('login_required', '0', TRUE)?>/>
						<label for="radio-not_login_required">비회원</label>
					</fieldset>
					<?=form_error('login_required')?>
				</li>
				<li data-role="list-divider" class="login-required-field">
					기타 조건
				</li>
				<!-- Template -->
				<li id="list-condition-template" class="list-condition-rule login-required-field" style="display:none;">
					<a class="condition-text">
					</a>
					<a class="condition-delete-button" data-role="button" data-iconpos="notext" data-icon="delete" data-theme="d">Delete</a>
					<input type="hidden" name="condition_rules[]" disabled="true"></input>
				</li>
				<!-- /Template -->
				<li data-role="fieldcontain" class="login-required-field">
					<p><a href="#page-add-condition" data-role="button" data-rel="dialog" data-transition="pop">조건 추가</a></p>
				</li>
				<li data-role="list-divider">
					문항
				</li>
				<!-- Template -->
				<li id="list-question-template" class="list-question" style="display:none;">
					<a>
						<h3>
							<span class="question-number"></span>
							<span class="question-title"></span>
						</h3>
						<p class="question-type">
							
						</p>
					</a>
					<a class="question-delete-button" data-role="button" data-iconpos="notext" data-icon="delete" data-theme="d">Delete</a>
					<input type="hidden" name="questions[]" disabled="true"></input>
				</li>
				<!-- /Template -->
				<li data-role="fieldcontain">
					<p><a href="#page-add-question" data-role="button" data-rel="dialog" data-transition="pop">문항 추가</a></p>
					<input name="questions_error" type="hidden" disabled="true"/>
				</li>
				<li data-role="list-divider"></li>
				<li class="ui-body ui-body-b">
					<fieldset class="ui-grid-a">
						<div class="ui-block-a">
							<button type="reset" data-theme="d">
								초기화
							</button>
						</div>
						<div class="ui-block-b">
							<button type="submit" data-theme="a">
								작성하기
							</button>
						</div>
					</fieldset>
				</li>
			</ul>
			<?=validation_errors()?>
		<?=form_close()?>
	</div><!-- /content -->
	<div data-role="footer" data-position="fixed">
		<?php $this->load->view('navbar', array('active' => 'create_poll')) ?>
	</div>
</div>

<!-- Start of third page: #page-add-condition -->
<div data-role="page" id="page-add-condition" data-theme="d">
	<div data-role="header">
		<h1>참여 조건 추가</h1>
		<a data-role="button" id="add-condition-button" data-icon="check" class="ui-btn-right">확인</a>
	</div><!-- /header -->

	<div data-role="content">
		<form>	
		<ul data-role="listview">
			<li data-role="list-divider">조건 선택</li>
			<li data-role="fieldcontain">
				<fieldset data-role="controlgroup" data-theme="a">
					<input type="checkbox" id="check-condition-address" name="condition[]" value="address" />
					<label for="check-condition-address">거주지</label>
					<input type="checkbox" id="check-condition-education" name="condition[]" value="education" />
					<label for="check-condition-education">최종학력</label>
					<input type="checkbox" id="check-condition-gender" name="condition[]" value="gender" />
					<label for="check-condition-gender">성별</label>
					<input type="checkbox" id="check-condition-age-range" name="condition[]" value="age_range" />
					<label for="check-condition-age-range">연령대</label>					
				</fieldset>
			</li>
			<li data-role="list-divider"></li>
			<li data-role="fieldcontain" id="condition-address">
				<fieldset data-role="controlgroup" class="address-selector">
					<legend class="field-label">거주지:</legend>
					<label for="address1">도/시</label>
					<?=form_dropdown('address1_id', $address[0], set_value('address1_id'), 'id="address1"')?>
					<label for="address2">시/군/구</label>
					<?=form_dropdown('address2_id', $address[1], set_value('address2_id'), 'id="address2"')?>	
					<label for="address3">동/읍/면</label>
					<?=form_dropdown('address3_id', $address[2], set_value('address3_id'), 'id="address3"')?>
				</fieldset>
			</li>
			<li data-role="fieldcontain" id="condition-education">
				<fieldset data-role="controlgroup" data-type="horizontal">
					<legend class="field-label">
						최종학력:
					</legend>
					<?=form_education_selector()?>
				</fieldset>
				<?=form_error('education')?>
			</li>
			<li data-role="fieldcontain" id="condition-gender">
				<fieldset data-role="controlgroup" data-type="horizontal">
					<legend class="field-label">
						성별:
					</legend>
					<input type="radio" value="male" name="gender" id="radio-gender-male" <?=set_radio('gender', 'male', TRUE)?>)/>
					<label for="radio-gender-male">남</label>
					<input type="radio" value="female" name="gender" id="radio-gender-female" <?=set_radio('gender', 'female')?>/>
					<label for="radio-gender-female">여</label>
				</fieldset>
				<?=form_error('gender')?>
			</li>
			
			<li data-role="fieldcontain" id="condition-age_range">
				<label for="age_range" class="field-label">연령:</label>
				<select name="age_range" id="age_range">
					<option value="">선택하세요</option>
					<option value="10">10대</option>
					<option value="20">20대</option>
					<option value="30">30대</option>
					<option value="40">40대</option>
					<option value="50">50대</option>
					<option value="60">60대</option>
					<option value="70">70대</option>
					<option value="80">80대</option>
					<option value="90">90대이상</option>
				</select>
			</li>
		</ul>
		</form>	
	</div><!-- /content -->
	<div data-role="footer">&nbsp;</div>
</div><!-- /page page-add-condition -->

<!-- Start of third page: #page-add-question -->
<div data-role="page" id="page-add-question" data-theme="d">
	<div data-role="header">
		<h1>문항 추가</h1>
		<a data-role="button" id="add-question-button" data-icon="check" class="ui-btn-right">확인</a>
	</div><!-- /header -->

	<div data-role="content">
		<form>	
		<ul data-role="listview">
			<li data-role="fieldcontain">
				<label for="text-question-title">질문: </label>
				<input type="text" id="text-question-title" name="title"/>
			</li>
			<li data-role="fieldcontain">
				<label for="select-question-type" class="field-label">유형:</label>
				<select name="type" id="select-question-type">
					<option value="choose-4">4지선다</option>
					<option value="choose-2">2지선다</option>
					<option value="choose-5">5지선다</option>
					<option value="text-short">단답형</option>
					<option value="text-long">긴 텍스트형</option>
					<option value="select">선택형</option>
				</select>
			</li>
			<!-- Template -->
			<li id="list-question-option-template" class="list-question-option" style="display:none;">
				<a><input type="text" name="options[]" disabled="true"/></a>
				<a class="option-delete-button" data-role="button" data-iconpos="notext" data-icon="delete" data-theme="d">Delete</a>
			</li>
			<!-- /Template -->
			<li data-role="list-divider" id="option-divider">보기</li>
			<li data-role="fieldcontain" id="list-add-option">
				<p><a id="button-add-option" data-role="button">추가</a></p>
			</li>
		</ul>
		</form>	
	</div><!-- /content -->
	<div data-role="footer">&nbsp;</div>
</div><!-- /page page-add-question -->

<?php $this->load->view('footer'); ?>